<?php
/**
 * Created by PhpStorm.
 * User: 11509
 * Date: 2021/4/2
 * Time: 15:12
 */

namespace app\admin\model;


use think\facade\Db;
use think\Model;

class Users extends Model
{

    public static function getUsersSel()
    {
        $sel = Users::select();
        return $sel;
    }


    public static function addUsersInfo($data)
    {

    }

    //Vip添加
    public static function addUsersVipInfo($data)
    {
        try{
            $res = Users::strict(true)->save($data);
            $msg='添加成功';
        }catch (\Exception $e){
            $res = false;
            $msg = $e->getMessage();
        }
        return [$res,$msg];
    }

    public static function usersEdit()
    {
        //模型更新
        //先根据ID或Where 条件查询
        // Db::raw('upwd+1');使用函数
        //save返回布尔值
        $data=[
            'id' =>'18',
            'uname'=>'圣僧'
        ];

        $obj=Users::where('id','=',$data['id'])->find();
        $obj->uname = $data['uname'];
        $obj->upwd = Db::raw('upwd+1');
        $res=$obj->force()->save();

    }
}